# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("//bazel:pl_build_system.bzl", "pl_cgo_library", "pl_go_test")

# gazelle:ignore
package(default_visibility = [
    "//src/carnot:__subpackages__",
    "//src/e2e_test/vizier/planner:__subpackages__",
    "//src/vizier:__subpackages__",
])

pl_cgo_library(
    name = "go_default_library",
    srcs = glob(
        include = ["logical_planner.go"],
        exclude = ["logical_planner_test.go"],
    ),
    cdeps = ["//src/carnot/planner:cgo_export"],
    cgo = True,
    importpath = "px.dev/pixie/src/carnot/goplanner",
    deps = [
        "//src/carnot/planner/compilerpb:compiler_status_pl_go_proto",
        "//src/carnot/planner/distributedpb:distributed_plan_pl_go_proto",
        "//src/carnot/planner/plannerpb:service_pl_go_proto",
        "//src/carnot/udfspb:udfs_pl_go_proto",
        "//src/common/base/statuspb:status_pl_go_proto",
        "//src/shared/scriptspb:scripts_pl_go_proto",
        "//src/table_store/schemapb:schema_pl_go_proto",
        "@com_github_gogo_protobuf//proto:go_default_library",
        "@com_github_gogo_protobuf//types:go_default_library",
        "@com_github_ianlancetaylor_cgosymbolizer//:go_default_library",
    ],
)

pl_go_test(
    name = "go_default_test",
    srcs = ["logical_planner_test.go"],
    deps = [
        ":go_default_library",
        "//src/carnot/planner/compilerpb:compiler_status_pl_go_proto",
        "//src/carnot/planner/distributedpb:distributed_plan_pl_go_proto",
        "//src/carnot/planner/dynamic_tracing/ir/logicalpb:logical_pl_go_proto",
        "//src/carnot/planner/plannerpb:service_pl_go_proto",
        "//src/carnot/planpb:plan_pl_go_proto",
        "//src/carnot/udfspb:udfs_pl_go_proto",
        "//src/common/base/statuspb:status_pl_go_proto",
        "//src/shared/scriptspb:scripts_pl_go_proto",
        "//src/table_store/schemapb:schema_pl_go_proto",
        "//src/vizier/funcs/go",
        "@com_github_gogo_protobuf//proto:go_default_library",
        "@com_github_sirupsen_logrus//:go_default_library",
        "@com_github_stretchr_testify//assert:go_default_library",
        "@com_github_stretchr_testify//require:go_default_library",
    ],
)

pl_go_test(
    name = "go_benchmark",
    srcs = [
        "logical_planner_benchmark_test.go",
        "schema_test.go",
    ],
    # This test has issues with GCC and libunwind.
    tags = ["no_gcc"],
    deps = [
        "//src/api/proto/uuidpb:uuid_pl_go_proto",
        "//src/api/proto/vispb:vis_pl_go_proto",
        "//src/api/proto/vizierpb:vizier_pl_go_proto",
        "//src/carnot/goplanner:go_default_library",
        "//src/carnot/planner/compilerpb:compiler_status_pl_go_proto",
        "//src/carnot/planner/distributedpb:distributed_plan_pl_go_proto",
        "//src/carnot/planner/dynamic_tracing/ir/logicalpb:logical_pl_go_proto",
        "//src/carnot/planner/plannerpb:service_pl_go_proto",
        "//src/carnot/planpb:plan_pl_go_proto",
        "//src/carnot/udfspb:udfs_pl_go_proto",
        "//src/common/base/statuspb:status_pl_go_proto",
        "//src/pixie_cli/pkg/vizier",
        "//src/shared/scriptspb:scripts_pl_go_proto",
        "//src/table_store/schemapb:schema_pl_go_proto",
        "//src/utils",
        "//src/utils/script",
        "//src/vizier/funcs/go",
        "//src/vizier/services/query_broker/controllers",
        "@com_github_gofrs_uuid//:go_default_library",
        "@com_github_gogo_protobuf//jsonpb:go_default_library",
        "@com_github_gogo_protobuf//proto:go_default_library",
        "@com_github_sirupsen_logrus//:go_default_library",
        "@com_github_stretchr_testify//assert:go_default_library",
    ],
)
